home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HPAVC
/
HPAVC CD-ROM.iso
/
FNTPAK32.ZIP
/
C.EXE
/
DEMOFNT1.C
< prev
next >
Wrap
C/C++ Source or Header
|
1995-08-16
|
6KB
|
209 lines
/**********************************************************************
DemoFnt1.C Copyright 1994, Rob W. Smetana
Turn Screen Swapping ON if appropriate.
Demonstrate how to CALL fonts. Use Font2Asm to create ASM/OBJ fonts.
Also demonstrates how to:
1. Determine whether an EGA/VGA monitor is being used.
2. Determine the default fontsize (8x14 (EGA) or 8x16 (VGA)).
Run DemoFnt2.C to see how to load Font Pak fonts from disk.
Requires:
Graphics.Lib
FONTS.obj <-- font-related ASM functions
HOLLOW9C.obj <-- these are CALLable fonts were
SCRIPT1.obj created by Font2Asm and A86.Com
FRAZZLE.obj
**********************************************************************/
#include <font_pak.h> /* for declarations -- PLEASE READ */
#include <stdio.h>
#include <graph.h>
void printdemo ();
/* ASM/OBJ fonts we'll CALL to load */
void extern pascal far HOLLOW9 (int Block);
void extern pascal far SCRIPT1 (int Block);
/* alternate line-draw characters; note how we load these on TOP of text */
void extern pascal far FRAZZLE (int Block);
/* "Block" would be 0-3 (EGA or VGA) or 0-7 (VGA only)
Syntax: RSLOADDefault(FontSize, Block); FontSize = 8, 14 or 16
Syntax: RSWHICHFONTS (Block1, Block2);
Syntax: HOLLOW9 (Block);
Syntax: SCRIPT1 (Block);
Syntax: FRAZZLE (Block);
*/
int GetFontSize (); /* local get-monitor function to detect EGA/VGA
and return size of default font (14/16)
-or- print error message if appropriate */
int main (void)
{
int Block0, Block1, Block2, Fontsize;
long BKColor;
short LOforeColor, HIforeColor;
BKColor = 1, LOforeColor = 7, HIforeColor = 14;
_setvideomode(_TEXTC80);
_setbkcolor(BKColor);
/*
Load fonts into Blocks 1 & 2 ; leave the default (0) alone.
Note that "loading" fonts does NOT "turn 'em on" (unless you
overwrite Block 0). We'll "activate" Blocks 1 - 3 shortly.
*/
Block0 = 0;
Block1 = 1; /* use Blocks 0 - 3 to ensure those with EGA */
Block2 = 2; /* monitors can see everything (ie., avoid 4-7) */
/*
PRE-Load Blocks 1 & 2. We're loading PARTIAL fonts, so this
step ensures we'll have something to use in each block.
*/
Fontsize = GetFontSize ();
if (Fontsize == 0)
return (-99);
RSLOADDEFAULT (Fontsize, Block1);
RSLOADDEFAULT (Fontsize, Block2);
/*
load custom fonts -- and 1 set of line characters.
*/
HOLLOW9 (Block1);
FRAZZLE (Block1);
SCRIPT1(Block2);
/* display some text, then "activate" different sets of Blocks */
_settextcolor(LOforeColor); /* 1st in LOW intensity */
printdemo();
_settextcolor(HIforeColor); /* then in HIGH intensity */
printdemo();
getch();
RSWHICHFONTS (Block1, Block2);
getch();
RSWHICHFONTS (Block2, Block0);
getch();
RSWHICHFONTS (Block2, Block1);
getch();
RSWHICHFONTS (Block0, Block2);
getch();
/*
Reload the default font into Blocks 1 and 2 (not really necessary)
*/
RSLOADDEFAULT (Fontsize, Block1);
RSLOADDEFAULT (Fontsize, Block2);
/*
To see what happens if you restore the wrong size font, un-comment this.
Try Fontsize = 8 and note the gaps in vertical lines.
Fontsize = 8;
RSLOADDEFAULT (Fontsize, Block1);
RSLOADDEFAULT (Fontsize, Block2);
getch();
*/
/* now return to Block 0 (the default) exclusively */
RSWHICHFONTS (Block0, Block0);
return(0);
} /* end main */
void printdemo ()
{
_outtext("\n ┌─░░░░░░░░░▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▓▓▓ FONT DEMO ▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒░░░░░░░░─┐ \n");
_outtext("░│ Note the different fonts here -- AND the different line-draw characters! │ \n");
_outtext("░│ ╒═══════╕ ╓──╖ ╓───╖ │ \n");
_outtext("░│ ┌──────┼─────┐ ╔══════╦═══════╗ ╒═════╧═════╕ │ ║ ─╫───╫────╜ ║ │ \n");
_outtext("░│ │ ├──── │ ║ ╚════╗ ╬═╗ │ ╒═════╪═╛ ║ ║ ║ ║ │ \n");
_outtext("░│ └──────┼─────┘ ╚═══════════╬══╝ ║ ╘═════╪═════╛ ║ ╙───╫────────╜ │ \n");
_outtext("░│ │ ╚════╝ ╘═════════ ╙──────╜ │ \n");
_outtext("░└──────────────────────────────────────────────────────────────────────────┘ \n");
_outtext("░░░░░░░░░░░░░░░░░░░░░░░░░press <SPACE> to change fonts░░░░░░░░░░░░░░░░░░░░░░ \n\n");
}
/*******************************************************************
Function: GetFontSize
Purpose: Check for EGA/VGA and return 14 (EGA 8x14), 16 (VGA 8x16).
Print an error message and return 0 if we're no EGA/VGA found.
GetMonitor returns an integer (0 - 8) indicating the type of monitor
in use. If two monitors are being used, GetMonitor returns
the type of the primary monitor.
*******************************************************************/
int GetFontSize ()
{
int MonType;
MonType = GETMONITOR();
switch (MonType) {
case 0, 1, 2: /* no monitor, Mono or CGA */
printf ("Sorry. An EGA or VGA monitor is required to run this demo. \n\n");
return (0);
break;
case 4: /* EGA. Set fontsize to 8x14 */
return (14);
break;
case 7, 8: /* VGA. Set fontsize to 8x16 */
return (16);
break;
default:
printf ("Unknown monitor type. Sorry. An EGA or VGA monitor is required to run this. \n\n");
return (0);
break;
}
}